﻿<%@ Page Title="Mobilhjulskift.dk - Glemt adgangskode" Language="C#" MasterPageFile="~/WebsiteSub.master" AutoEventWireup="true" CodeBehind="Glemt.aspx.cs" Inherits="TireService.Website.Glemt" %>

<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxLoadingPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">

    <dx:ASPxLoadingPanel ID="LoadingPanel" Text="Vent venligst..." ClientInstanceName="LoadingPanel" runat="server" Modal="True">
    </dx:ASPxLoadingPanel>

    <!-- JavaScript for handling reset of password -->
    <script type="text/javascript" language="javascript">

        // Function for resetting password
        function ResetPassword() {

            // Validate values
            txtEmail.Validate();

            var isFormValid = ASPxClientEdit.ValidateGroup("ForgotLogin");
            if (isFormValid) {
                var email = txtEmail.GetText();
                
                // Perform server callback and reset user password
                callBackResetPassword.PerformCallback(email);

                // Show loadingpanel while posting back
                LoadingPanel.Show();
            }
        }

        function OnCallbackResetPasswordComplete(s, e) {
            // Hide loadingpanel after postback
            LoadingPanel.Hide();

            var values = e.result.split("|");

            if (values[0] == 0) {
                alert(values[1]);
            }

            if (values[0] == 1) {
                alert('Adgangskode er blevet nulstillet og en ny er sendt på email');

                txtEmail.SetText('');
            }
        }

        function CallBackError(s, e) {
            // Hide loadingpanel in case it is running
            LoadingPanel.Hide();

            alert('Fejl opstod: ' + e.message);
        }

    </script>

    <dx:ASPxCallback ID="callBackResetPassword" ClientInstanceName="callBackResetPassword" runat="server" OnCallback="callBackResetPassword_Callback">
        <ClientSideEvents CallbackError="CallBackError" CallbackComplete="OnCallbackResetPasswordComplete" />
    </dx:ASPxCallback>

<div id="box1">

    <h1>Glemt adgangskode</h1>
    
    <p class="normaltext">
        <table>
            <tr>
                <td>
                    <dx:ASPxLabel ID="lblForgotLogin" runat="server" Text="Indtast email">
                    </dx:ASPxLabel>
                </td>
                <td>
                    <dx:ASPxTextBox ID="txtEmail" ClientInstanceName="txtEmail" runat="server" Width="182px"
                        ClientIDMode="AutoID" MaxLength="100">
                        <ClientSideEvents KeyDown="function(s, e) {if(ASPxClientUtils.GetKeyCode(e.htmlEvent) ===  ASPxKey.Enter) ResetPassword();}" />
                        <ValidationSettings RegularExpression-ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                            ErrorDisplayMode="ImageWithTooltip" RegularExpression-ErrorText="Email ikke gyldig"
                            RequiredField-IsRequired="true" RequiredField-ErrorText="Venligst udfyld email adresse"
                            ValidationGroup="ForgotLogin">
                        </ValidationSettings>
                    </dx:ASPxTextBox>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <dx:ASPxButton ID="btnResetPassword" ClientInstanceName="btnResetPassword" runat="server"
                        Text="Send ny adgangskode" AutoPostBack="False" UseSubmitBehavior="False">
                        <ClientSideEvents Click="function(s, e) { ResetPassword(); }" />
                    </dx:ASPxButton>
                </td>
            </tr>
        </table>

        <%--<asp:PasswordRecovery ID="PasswordRecovery1" runat="server" CssClass="normaltext" 
            AnswerLabelText="Svar:" AnswerRequiredErrorMessage="Svar skal udfyldes." 
            GeneralFailureText="Forsøg på at få tilsendt adgangskode fejlede. Venligst prøv igen." 
            QuestionFailureText="Dit svar var ikke korrekt. Venligst prøv igen." 
            QuestionInstructionText="Besvar følgende spørgsmål for at få tilsendt din adgangskode." 
            QuestionLabelText="Spørgsmål:" QuestionTitleText="Identitets konfirmation" 
            SubmitButtonText="Send" SuccessText="Din adgangskode er blevet sendt til dig." 
            UserNameFailureText="Dine informationer kunne ikke tilgås. Venligst prøv igen." 
            UserNameInstructionText="Indtast brugernavn for at få tilsendt din adgangskode." 
            UserNameLabelText="Brugernavn/Email:" 
            UserNameRequiredErrorMessage="Brugernavn skal udfyldes." 
            UserNameTitleText="Glemt din adgangskode?"
            MembershipProvider="AspNetSqlMembershipProvider" Width="374px">
            <MailDefinition From="support@mobilhjulskift.dk" Subject="Mobilhjulskift.dk - Glemt adgangskode" BodyFileName="~/HTMLTemplates/EmailGlemtAdgangskode.htm" IsBodyHtml="True">
            </MailDefinition>
        </asp:PasswordRecovery>--%>
    </p>

</div>

</asp:Content>
